package com.goambu.driver.framework.view;

import android.os.AsyncTask;

public class LoadTask extends AsyncTask<Void, Integer, Void> {
	// Before running code in the separate thread
	Loadingable component;

	public LoadTask(Loadingable component) {
		this.component = component;
	}

	@Override
	protected void onPreExecute() {
		component.beforeLoadingData();
	}

	@Override
	protected Void doInBackground(Void... params) {
		// Get the current thread's token
		synchronized (this) {
			component.loadingData();
		}

		return null;

	}

	@Override
	protected void onPostExecute(Void result) {
		component.afterLoadingData();
	}

}